local GuildWarChallengeTabPanel = app.mvc.createPanelClass(...)
local GuildWarChanllengeRender = import("..renders.GuildWarChanllengeRender")
local CrossServerGuildWarHelper = require("app.crossServer.views.guildWar.CrossServerGuildWarHelper")

--data =
function GuildWarChallengeTabPanel.createWithData(data, node)
    local sprite = GuildWarChallengeTabPanel.extend(node)
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end

function GuildWarChallengeTabPanel.create(node)
    return GuildWarChallengeTabPanel.createWithData(nil, node)
end

function GuildWarChallengeTabPanel:init(data)
    self.super.init(self, data)
    local taskRenders = {}
    for i = 1, 4 do
        local render = GuildWarChanllengeRender.create(self._ui["Panel/node_"..i])
        render:setIndex(i)
        table.insert( taskRenders,  render)
    end
    self._taskRenders = taskRenders
    self._tasksData = CrossServerGuildWarHelper.getTasks()
    self:refresh()
end


function GuildWarChallengeTabPanel:onTabSelect()
end

function GuildWarChallengeTabPanel:refresh()  
    for k, v in pairs(self._taskRenders) do
        local task = self._tasksData[k]
        v:setData(task)
    end
end

function GuildWarChallengeTabPanel:setPanelTabIndex(index)
    self._tabPanelIndex = index
end

return GuildWarChallengeTabPanel